/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package ejb.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author simone
 */
@Entity
@Table(name = "Citta")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Citta.findAll", query = "SELECT c FROM Citta c"),
    @NamedQuery(name = "Citta.findByIdCitta", query = "SELECT c FROM Citta c WHERE c.idCitta = :idCitta"),
    @NamedQuery(name = "Citta.findByCountry", query = "SELECT c FROM Citta c WHERE c.country = :country"),
    @NamedQuery(name = "Citta.findByCity", query = "SELECT c FROM Citta c WHERE c.city = :city")})
public class Citta implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_citta")
    private Integer idCitta;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 25)
    @Column(name = "country")
    private String country;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 40)
    @Column(name = "city")
    private String city;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkCitta")
    private Collection<Escursione> escursioneCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkPartenza")
    private Collection<Viaggio> viaggioCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkArrivo")
    private Collection<Viaggio> viaggioCollection1;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkCitta")
    private Collection<Hotel> hotelCollection;

    public Citta() {
    }

    public Citta(Integer idCitta) {
        this.idCitta = idCitta;
    }

    public Citta(Integer idCitta, String country, String city) {
        this.idCitta = idCitta;
        this.country = country;
        this.city = city;
    }

    public Integer getIdCitta() {
        return idCitta;
    }

    public void setIdCitta(Integer idCitta) {
        this.idCitta = idCitta;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    @XmlTransient
    public Collection<Escursione> getEscursioneCollection() {
        return escursioneCollection;
    }

    public void setEscursioneCollection(Collection<Escursione> escursioneCollection) {
        this.escursioneCollection = escursioneCollection;
    }

    @XmlTransient
    public Collection<Viaggio> getViaggioCollection() {
        return viaggioCollection;
    }

    public void setViaggioCollection(Collection<Viaggio> viaggioCollection) {
        this.viaggioCollection = viaggioCollection;
    }

    @XmlTransient
    public Collection<Viaggio> getViaggioCollection1() {
        return viaggioCollection1;
    }

    public void setViaggioCollection1(Collection<Viaggio> viaggioCollection1) {
        this.viaggioCollection1 = viaggioCollection1;
    }

    @XmlTransient
    public Collection<Hotel> getHotelCollection() {
        return hotelCollection;
    }

    public void setHotelCollection(Collection<Hotel> hotelCollection) {
        this.hotelCollection = hotelCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCitta != null ? idCitta.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Citta)) {
            return false;
        }
        Citta other = (Citta) object;
        if ((this.idCitta == null && other.idCitta != null) || (this.idCitta != null && !this.idCitta.equals(other.idCitta))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ejb.entities.Citta[ idCitta=" + idCitta + " ]";
    }
    
}
